<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>商品编辑</h2>
    </div>
    <hr>
    <form action="" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">商品名称</label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$info.name}">
                <input type="hidden" name="id" value="{$info.id}"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">兑换积分</label>
            <div class="controls">
                <input type="number" class="text input-large" name="integral" value="{$info.integral}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">购买价格（元）</label>
            <div class="controls">
                <input type="number" class="text input-large" name="money" value="{$info.money}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">商品详情</label>
            <div class="controls">
                <label class="textarea input-large">
                    <textarea name="content">{$info.content}</textarea>
                </label>
            </div>
        </div>
        <div class="form-item" id="pic_hidden">
            <label class="item-label">商品图片</label>
            <volist name="pic" id="vo">
                <input type="hidden" value="{$vo}" name="pic_old[]"/>
            </volist>
        </div>

    </form>
    <div class="controls">
        <input type="file" id="file_upload">
        <div id="div_pic" class="upload-pre-item">
            {$picimg}
        </div>
    </div>
    <br/>
    <br/>
    <br/>
    <br/>
    <div class="controls">
        <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
    </div>
</block>

<block name="script">
    <script>
        function uploadPicture(file, data)
        {
            var data = $.parseJSON(data);
            var src = '__ROOT__/Uploads/'+data.savepath+data.savename;
            var h_val = '/Uploads/'+data.savepath+data.savename;
            var input = "<input value='"+h_val+"'  type='hidden' name='pic[]'/>";
            $('#pic_hidden').append(input);
            var img = "<img src='"+src+"'  width='200' height='200'/>";
            $('#div_pic').append(img);

        }
        $(function () {
            $("#file_upload").uploadify({
                "height"          : 30,
                "swf"             : "__STATIC__/uploadify/uploadify.swf",
                "fileObjName"     : "download",
                "buttonText"      : "上传图片",
                "uploader"        : "{:U('File/member_upload')}",
                "width"           : 120,
                'removeTimeout'	  : 1,
                'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                "onUploadSuccess" : uploadPicture,
                'onFallback' : function() {
                    alert('未检测到兼容版本的Flash.');
                }
            });
        });
    </script>
</block>
